<?php $this->load->view('_inc/header_popup'); ?>

<?php echo form_open('turma/fecharChamada', 'class="presenca-aula"'); ?>
    <div class="presenca-aula-header row-fluid">
        <div class="span4">
            <?php echo form_hidden('turma',$turma->id)?>
            <p><b>Código da Disciplina: </b>116734</p>
            <p><b>Turma: </b><?php echo $turma->letra?></p>
            <p><b>Período: </b><?php echo $turma->semestre?></p>
            <p><b>Data da aula: </b></p><input id="data-aula" name="data" type="date" />
        </div>
        <div class="span6">
            <p><b>Nome da Disciplina: </b><?php echo $turma->disciplina?></p>
            <p><b>Professor: </b><?php echo $turma->nome?></p>
            <p><b>Tema da aula: </b></p><?php echo form_input('tema','','id=descricao-aula')?>
        </div>
        <div class="span2">
            <div class="actions">
                <button class="btn btn-primary" type="submit">Salvar</button>
                <button class="btn cancel" type="button">Cancelar</button>
            </div>
        </div>
    </div>
    <div class="presenca-aula-content row-fluid">
        <div class="span1"><img id="prev" src="<?php echo base_url() ?>public/imagens/icones/seta-left.png"></div>
        <div class="span10">
            <div class="slider" style="width: 100%;">
                <?php foreach ($alunos as $aluno) { ?>
                <div class="row-fluid">
                    <div class="span5 foto valign">
                        <img class="img-rounded" src="<?php echo base_url()?>public/fotos/<?php echo $aluno->id?>.jpg">
                    </div>
                    <div class="span6 offset1 infos valign">
                        <div>
                            <div class="aluno-info">
                                <?php echo form_hidden('alunos[]', $aluno->id);?>
                                <p><b>Nome: </b> <?php echo $aluno->nome; ?></p>
                                <p><b>Matrícula: </b><?php echo $aluno->matricula; ?></p>
                                <p><b>Curso: </b><?php echo $aluno->curso; ?></p>
                            </div>
                            <div class="row-fluid">
                                <div class="span12">
                                    <table style="height:100%;width:100%;"><tr>
                                        <td>
                                            <div class="btn-group btn-group-vertical tipo-presenca">
                                                <a class="btn btn-large" href="#">Presente</a>
                                                <a class="btn btn-large" href="#">Atraso</a>
                                                <a class="btn btn-large" href="#">Saiu mais cedo</a>
                                                <a class="btn btn-large" href="#">Falta</a>
                                                <?php echo form_hidden('presencas[]', 'Presente');?>
                                            </div>
                                        </td>
                                        <td>
                                            <p><label>Observações: </label><p>
                                            <textarea name="observacoes[]" rows="7"></textarea>
                                        </td>
                                    </tr></table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <?php } ?>
            </div>
        </div>
        <div class="span1"><img id="next" src="<?php echo base_url(); ?>public/imagens/icones/seta-right.png"></div>
    </div>
<?php echo form_close() ?>
<script type="text/javascript">
    function chamadaReady() {
        $('.presenca-aula-content').height($('.presenca-aula').height() - 25 - $('.presenca-aula-header').height());
        $(window).resize(function() { $('.presenca-aula-content').height($('.presenca-aula').height() - 25 - $('.presenca-aula-header').height()); })
        
        $('.valign > *').each(function() {
            var pHeight = $(this).parent().height();
            var tHeight = $(this).height();
            var top = (((pHeight - tHeight) / 2) / pHeight) * 100;
            $(this).parent().css('position', 'relative');
            $(this).css('position', 'absolute');
            $(this).css('top', top + '%'); 
        });
        $(window).resize(function() {
            $('.valign > *').each(function() {
                var pHeight = $(this).parent().height();
                var tHeight = $(this).height();
                var top = (((pHeight - tHeight) / 2) / pHeight) * 100;
                $(this).parent().css('position', 'relative');
                $(this).css('position', 'absolute');
                $(this).css('top', top + '%'); 
            });
        });
        
        $('.slider').cycle({
            fx: 'scrollHorz',
            speed: 500,
            timeout: 0,
            next: '#next',
            prev: '#prev',
            fit: true
        });
        
        $('.cancel').click(function() {
            $('.popUpBack2').fadeOut(500);
        });

        $('.tipo-presenca a:nth-child(1)').click(function() {
            $(this).parent().find('a').each(function() {
                $(this).removeClass('btn-success');
                $(this).removeClass('btn-warning');
                $(this).removeClass('btn-danger');
                $(this).removeClass('btn-primary');
            });
            $(this).addClass('btn-success');
            $(this).next('a').next('a').next('a').next('input').val('Presente');
        });
        $('.tipo-presenca a:nth-child(2)').click(function() {
            $(this).parent().find('a').each(function() {
                $(this).removeClass('btn-success');
                $(this).removeClass('btn-warning');
                $(this).removeClass('btn-danger');
                $(this).removeClass('btn-primary');
            });
            $(this).addClass('btn-warning');
            $(this).next('a').next('a').next('input').val('Atraso');
        });
        $('.tipo-presenca a:nth-child(3)').click(function() {
            $(this).parent().find('a').each(function() {
                $(this).removeClass('btn-success');
                $(this).removeClass('btn-warning');
                $(this).removeClass('btn-danger');
                $(this).removeClass('btn-primary');
            });
            $(this).addClass('btn-primary');
            $(this).next('a').next('input').val('Saiu mais cedo');
        });
        $('.tipo-presenca a:nth-child(4)').click(function() {
            $(this).parent().find('a').each(function() {
                $(this).removeClass('btn-success');
                $(this).removeClass('btn-warning');
                $(this).removeClass('btn-danger');
                $(this).removeClass('btn-primary');
            });
            $(this).addClass('btn-danger');
            $(this).next('input').val('Falta');
        });
    };
</script>